#ifndef _SNAKE_HPP_
#define _SNAKE_HPP_

#include "game.hpp"

class Snake {
  unsigned int length = 2;
  /* 0 = no move
   * 1 = left
   * 2 = up
   * 3 = right
   * 4 = down */
  unsigned char direction = 0;
  std::list<unsigned int> history;
  bool getBigger = false;
  Game &locGame;

  template <typename _comp, typename _lambda>
  void define_direction(_comp comp, _lambda head);

public:
  /* 0 = no move
   * 1 = left
   * 2 = up
   * 3 = right
   * 4 = down */
  void set_direction(char n) {
    if (direction == 0 or std::abs(direction - n) != 2)
      direction = n;
  }
  Snake(Game &my_game);
  void cycle();
  const auto &get_history() { return history; };
};

#endif // !_SNAKE_HPP_
